<?php
namespace app\service;
use app\model\MemberCoin;



class MemberCoinService extends BaseService
{
    protected function setModel(): string
    {
        return MemberCoin::class;
    }

    public function getTotalRechargeByMid($mids)
    {
        $rechargeMap =[];
        $payCoinService = app()->make(PayCoinService::class);
        $list = $this->getAll(["member_id"=>$mids],"coin_id,member_id,account_amount,frozen_amount");
        $coinMap = $payCoinService->getCoins();
        foreach ($mids as $mid) {
            $sum =0;
            foreach ($list as $memberCoin) {
                $code = $coinMap[$memberCoin->coin_id];
                if ($mid ==$memberCoin->member_id) {
                     $sum+=h_money_switch($code,$memberCoin->account_amount);
                }
            }
            
            $rechargeMap[$mid] = $sum;
        }
        return $rechargeMap;
    }
}